package com.andy.wan.android.mvp.ui.adapter;

import com.andy.wan.android.R;
import com.andy.wan.android.mvp.bean.NavigationListData;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import androidx.annotation.NonNull;

/**
 * @Author: luofan
 * @CreateDate: 2020/4/1 16:27
 * @Description:
 */
public class NavigationAdapter extends BaseQuickAdapter<NavigationListData, BaseViewHolder> {

    private int mSelectPosition;

    public NavigationAdapter() {
        super(R.layout.adapter_navigation);
    }

    public void setSelectPosition(int selectPosition) {
        notifyItemChanged(mSelectPosition);
        mSelectPosition = selectPosition;
        notifyItemChanged(selectPosition);
    }

    public int getSelectPosition() {
        return mSelectPosition;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, NavigationListData item) {
        helper.setGone(R.id.view_select, helper.getAdapterPosition() == mSelectPosition);
        helper.setText(R.id.tv_name, item.getName());
    }
}
